<?php

/**
 * FileName: SystemSettingBasicForm.php
 * Author: 790213952@qq.com
 * DateTime: 2024/8/7 下午12:34
 * SystemName: Ymtc
 *
 */


/**
 * FileName: SiteConfig.php
 * Author: Xiao Yao <790213952@qq.com>
 * DateTime: 2022-09-15 下午 02:23
 * Summary:
 */


namespace YmPhp\Admin\Http\Forms;


use YmPhp\Admin\Models\Setting as SystemSettingModel;
use YmPhp\Admin\Widgets\Form;

class SystemSettingGuideConfigForm extends Form
{
    /**
     * The form title.
     *
     * @var string
     */
    public $title = '基本设置';

    /**
     * Handle the form request.
     *
     * @param Request $request
     *
     */
    public function handle(array $input)
    {
        (new SystemSettingModel())->saveConfig($input, 'system_guide');
        return $this->response()->success('保存成功')->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {

        $this->tab(trans('setting.basic.basic_settings'), function () {
            $this->textarea('guide_content', trans('guide.guide_content'))->help(trans('guide.guide_content_msg'))->width('5');
            $this->color('guide_btn_bg_color',trans('guide.guide_btn_bg_color'))->default('#3275fa');
            $this->text('guide_border_radius',trans('guide.guide_border_radius'))->width('3');
            $this->text('guide_border_radius_msg',trans('guide.guide_border_radius_msg'))->width('3');
            $this->color('guide_main_wordc',trans('guide.guide_main_wordc'));
            $this->color('guide_sub_wordc',trans('guide.guide_sub_wordc'));
            $this->text('guide_opacity',trans('guide.guide_opacity'))->help(trans('guide.guide_opacity_msg'))->width('3');
            $this->color('guide_bg_color',trans('guide.guide_bg_color'))->default('#BFC1C3');
            $this->radio('guide_is_auto_show',trans('guide.guide_is_auto_show'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')]);
            $this->radio('guide_show_pos',trans('guide.guide_show_pos'))->options([1=>trans('guide.guide_show_pos1') , 2 => trans('guide.guide_show_pos2') ]);
            $this->text('guide_show_time',trans('guide.guide_show_time'))->help(trans('guide.guide_show_time_msg'))->width('3');
            $this->radio('guide_login',trans('guide.guide_login'))->options(['0' => trans('setting.basic.close'), '1' => trans('setting.basic.open')]);

        });
    }

    /**
     * The data of the form.
     *
     * @return array $data
     */
    public function data()
    {
        $datas = SystemSettingModel::pluck('value', 'key');
        return $datas['system_guide'];
    }


}

